clear
rng default
%% Load useful matrices
load G_round
x=4;
all_years=1940:1:1967;
n_years=size(all_years,2);
n=7^4;
p=n*(n-1)/2;
m=p;
random_indices_pairs = randperm(p, m).';
%% Construct grid
u0grid=0;
u1grid=1; %it will be replaced in f_s
u2grid=linspace(G_round_larger{x,2}(1),G_round_larger{x,2}(2),100); 
u3grid=linspace(G_round_larger{x,3}(1),G_round_larger{x,3}(2),100); 
u4grid=linspace(G_round_larger{x,4}(1),G_round_larger{x,4}(2),100); 
% try different sizes of grid hypercube as discussed in Appendix C of the paper (need powerful cluster to run the code for larger sizes of grid hypercube)
[ca, cb, cc,cd, ce] = ndgrid(u0grid, u1grid, u2grid, u3grid, u4grid);
u0grid=ca(:);
u1grid=cb(:);
u2grid=cc(:);
u3grid=cd(:);
u4grid=ce(:);

%% Workers
workers=600; %number of parallel workers
jobs=round(size(u2grid,1)/workers); %number of jobs per parallel worker

